﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using System.Threading;
using MovieWebApp.App_Code.Entities;
using MovieWebApp.DataAccess;
using MovieWebApp.DatabaseMarkup;

namespace MovieWebApp.Pages
{
    public partial class Search : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //DataSet genresDS = new DataSet();
                //genresDS.ReadXml(MapPath("~/Assets/Genres.xml"));
                //ddlGenres.DataSource = genresDS;
                //ddlGenres.DataBind();
                //ddlGenres.Items.Insert(0, "-- All Genres --");
            }
        }

        protected override void InitializeCulture()
        {
            if ((string)Session["Language"] != null)
            {
                string selectedLanguage = (string)Session["Language"];
                UICulture = selectedLanguage;
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectedLanguage);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(selectedLanguage);
            }
            base.InitializeCulture();
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string searchString = boxSearch.Text;
            string filterType = ddlFilter.SelectedValue;

            List<Movies> p = MovieAccess.GetAllMoviesBySearch(searchString, filterType);
            pList.DataSource = p;
            pList.DataBind();

            pList.Visible = true;
        }

        protected void ddlFilter_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void AddToCartLink(object sender, EventArgs e)
        {
            LinkButton clickedLink = (LinkButton)sender;
        }

        protected void pList_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        
    }
}
